package cn.ac.iscas.dba;

import java.net.UnknownHostException;

import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.Mongo;
import com.mongodb.MongoException;

/**
 * @author Simon@itechs
 *
 */
public class BasicDBA {
	private static Mongo m = null;
	public static DBCollection connection;
	public BasicDBA(){
		try {
			if (m == null){
				m = new Mongo(Constants.host);
				DB db = m.getDB(Constants.dbName);
				DBCollection coll = db.getCollection(Constants.collectionName);
				connection = coll;
			}
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (MongoException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void closeConnection(){
		m.close();
	}
}
